<%@ page language="java" pageEncoding="UTF-8" %>
<!doctype html>
<html lang="zh-CN">
<head>
    <%@include file="/WEB-INF/views/commons/common.jsp" %>
    <link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/bootstrap/3.3.5/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css"
          href="${base_href}/static/ui-frame/bootstrap-dialog3/css/bootstrap-dialog.css">
    <link rel="stylesheet" type="text/css"
          href="${base_href}/static/ui-frame/validation-engine/validationEngine.jquery.css">
    <link rel="stylesheet" type="text/css"
          href="${base_href}/static/ui-frame/jquery-easyui/1.4.3/themes/metro/easyui.css">
    <link rel="stylesheet" type="text/css"
          href="${base_href}/static/ui-frame/font-awesome/4.3.0/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/bootstrap/3.3.5/css/build.css">

    <link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/webuploader/0.1.5/webuploader.css">
    <link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/viewer/viewer.css">
    <link rel="stylesheet" type="text/css" href="${base_href}//static/ui-frame/ztree-v3/css/zTreeStyle/zTreeStyle.css">

    <link rel="stylesheet" type="text/css" href="${base_href}/static/css/search-theme.css">
    <link rel="stylesheet" type="text/css" href="${base_href}/static/css/form-theme.css">
    <link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/layui-v2.3.0/layui/css/layui.css">

    <title>每日打卡审核</title>
</head>
<body data-spy="scroll" data-target="#myScrollspy" data-offset="350">


<div class="main-wrap">

    <!-- 工具条 start-->
    <div class="container-fluid form-body-header">
        <div class="container">
            <div class="row tool-bar">
                <div class="col-xs-12">
                    <button type="button" class="btn btn-sm tool-btn" id="saveBtn">提交审核记录</button>
                </div>
            </div>
        </div>
    </div>
    <!-- 工具条 end-->

    <!-- 表单 start-->
    <div class="container-fluid">
        <form id="form">
            <input type="hidden" name="studentDailyClockId" value="${form.studentDailyClockId }"/>

            <div class="container form-body-div">
                <div class="row text-center title-body" id="baseinfo">
                    每日打卡<br/>
                </div>

                <div class="row pannel-title">
                    <span>基本信息</span> <a href="javascript:void(0);" class="hide-next-btn">收起</a>
                </div>
                <div class="row pannel-body">
                    <table class="form-table">
                        <tr>
                            <th class="col-xs-2 ">英语打卡</th>
                            <td class="col-xs-4 englishClockUpload" colspan="3">
                            </td>
                        </tr>
                        <tr>
                            <th class="col-xs-2 ">英语打卡审核</th>
                            <td class="col-xs-4" colspan="3">
                                <select name="englishStudyState" class="form-control validate[required]">
                                      <option value="0" <c:if test="${'0' eq form.englishStudyState }">selected="selected"</c:if>>
                                        未上传图片
                                      </option>
                                      <option value="1" <c:if test="${'1' eq form.englishStudyState }">selected="selected"</c:if>>
                                        未审核
                                      </option>
                                      <option value="2" <c:if test="${'2' eq form.englishStudyState }">selected="selected"</c:if>>
                                        审核通过
                                      </option>
                                      <option value="3" <c:if test="${'3' eq form.englishStudyState }">selected="selected"</c:if>>
                                        审核不通过
                                      </option>
                                  </select>
                            </td>
                        </tr>
                        <tr>
                            <th class="col-xs-2 ">每日学习情况</th>
                            <td class="col-xs-4" colspan="3">
                            </td>
                        </tr>
                         <tr>
                            <c:forEach items="${books}" var="book" varStatus="bookStatus">
                                <input type="hidden" name="books" value="${book.bookId}----${book.bookName}"/>
                            </c:forEach>
                            <input type="hidden" id="exerciseIndex" value="${fn:length(form.exerciseCompletionDTOS)}"/>
                            <th class="col-xs-2 ">科目名</th>
                            <th class="col-xs-2 ">题目开始序号</th>
                            <th class="col-xs-2 ">题目结束序号</th>
                            <th class="col-xs-2 "></th>
                        </tr>
                        <c:forEach items="${form.exerciseCompletionDTOS}" var="exerciseCompletion" varStatus="exerciseCompletionStatus">
                            <tr>
                                <td class="col-xs-2">
                                <input type="hidden" name="exerciseCompletionDTOS['${exerciseCompletionStatus.index}'].exerciseBookId" value="${exerciseCompletion.exerciseBookId}"/>
                                  <select name="exerciseCompletionDTOS['${exerciseCompletionStatus.index}'].exerciseBookId" disabled="disabled" class="form-control">
                                      <option value="" selected="selected">请选择</option>
                                      <c:forEach items="${books}" var="book" varStatus="bookStatus">
                                          <option value="${book.bookId}"
                                            <c:if test="${exerciseCompletion.exerciseBookId eq book.bookId }">selected="selected"</c:if>>
                                            ${book.bookName}
                                          </option>
                                      </c:forEach>
                                  </select>
                                </td>
                                <td class="col-xs-2">
                                    <input type="text" class="form-control validate[required]" readonly="readonly"  name="exerciseCompletionDTOS['${exerciseCompletionStatus.index}'].startExerciseNum"
                                       value="${exerciseCompletion.startExerciseNum}"/>
                                </td>
                                <td class="col-xs-2">
                                    <input type="text" class="form-control validate[required]" readonly="readonly"  name="exerciseCompletionDTOS['${exerciseCompletionStatus.index}'].endExerciseNum"
                                       value="${exerciseCompletion.endExerciseNum}"/>
                                </td>
                                <td class="col-xs-2">
                                </td>
                           </tr>
                        </c:forEach>
                        <tr>
                            <th class="col-xs-2 ">每日任务正确题目数</th>
                            <td class="col-xs-2">
                               <span>${form.dailyTaskCorrectNum}</span>
                            </td>
                            <th class="col-xs-2 ">每日任务总题目数</th>
                            <td class="col-xs-2">
                               <span>${form.dailyTaskTotalNum}</span>
                            </td>
                        </tr>
                        <tr>
                            <th class="col-xs-2 ">录播课实际播放节数</th>
                            <td class="col-xs-2">
                                <span>${form.recordedBroadcastTotalNum}</span>
                            </td>
                            <th class="col-xs-2 ">录播课应播放节数</th>
                            <td class="col-xs-2">
                                <span>${form.recordedBroadcastTotalNum}</span>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </form>
    </div>
    <!-- 表单 end-->

</div>
<script type="text/javascript" src="${base_href}/static/ui-frame/jquery/1.11.3/jquery.js"></script>
<script type="text/javascript" src="${base_href}/static/ui-frame/bootstrap/3.3.5/js/bootstrap.js"></script>
<script type="text/javascript" src="${base_href}/static/ui-frame/bootstrap-dialog3/js/bootstrap-dialog.js"></script>
<script type="text/javascript"
        src="${base_href}/static/ui-frame/validation-engine/jquery.validationEngine-zh_CN.js"></script>
<script type="text/javascript" src="${base_href}/static/ui-frame/validation-engine/jquery.validationEngine.js"></script>
<script type="text/javascript" src="${base_href}/static/ui-frame/My97DatePicker/WdatePicker.js"></script>

<script type="text/javascript" src="${base_href}/static/ui-frame/layer/layer.js"></script>
<script type="text/javascript" src="${base_href}/static/ui-frame/layui-v2.3.0/layui/layui.js"></script>

<script type="text/javascript" src="${base_href}/static/support/dailyclock/dailyclock-attach-read.js"></script>

<script type="text/javascript">
    $(function () {
        $('#form').validationEngine('attach', {
            maxErrorsPerField: 1,
            scroll: false,
            validationEventTrigger: "keyup blur change focus",
            ValidateNoneVisibleFields: true,//验证隐藏域
            promptPosition: "topRight" //验证弹出框的位置，topRight,topLeft,bottomRight,bottomLeft,centerRight,centerLeft,inline
        });

        $("#saveBtn").click(function () {
            if ($("input[name='paperName']").validationEngine('validate')) {
                return $.post(basePath + "/dailyClock/auditDailyClock.json", $("#form").serialize(), function (res) {
                var message = res.message
                if(res.code == 0){
                    message = "保存成功"
                }
                BootstrapDialog.show({
                    title: "提示框",
                    message: message,
                    buttons: [{
                        label: "确认",
                        action: function (dialog) {
                            dialog.close();
                        }
                    }]
                });

                }, 'json')
                    .error(function (a, b, c) {
                        var message = a.responseText;
                        if (a.responseText.indexOf("Duplicate entry") > -1) {
                            var start = a.responseText.indexOf("Duplicate entry");
                            var end = a.responseText.indexOf("ques_code");
                            end = end + 13;
                            message = a.responseText.substring(start, end);
                        }
                        BootstrapDialog.show({
                            title: "保存失败",
                            message: message,
                            buttons: [{
                                label: "确认",
                                action: function (dialog) {
                                    dialog.close();
                                }
                            }]
                        });

                    });
            }
        });

    });
</script>
</body>
</html>
